home *** CD-ROM | disk | FTP | other *** search
- #include <OSUtils.h>
- #include <Events.h>
- #include <EPPC.h>
- #include <Processes.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include "crtlocal.h"
-
- static OSErr waitforcompletion(volatile OSErr *err)
- {
- while (*err == 1)
- {
- ProcessSerialNumber mysn = {0, 0};
- EventRecord event;
- mysn.lowLongOfPSN = kSystemProcess;
- SetFrontProcess(&mysn);
- WaitNextEvent(0x0, &event, 60, NULL);
- mysn.lowLongOfPSN = kCurrentProcess;
- SetFrontProcess(&mysn);
- }
- return *err;
- }
-
- long readpipe(int fd, char *readbuffer, long size)
- {
- OSErr err;
- PPCReadPBRec thedata;
- thedata.sessRefNum = crt_fd_tab[fd].fd;
- thedata.ioCompletion = 0;
- thedata.bufferLength = size;
- thedata.bufferPtr = readbuffer;
- err = PPCReadAsync(&thedata);
- err = waitforcompletion(&thedata.ioResult);
- return thedata.actualLength;
- }
-
- long writepipe(int fd, char *writebuffer, long size)
- {
- OSErr err;
- PPCWritePBRec thedata;
- thedata.sessRefNum = crt_fd_tab[fd].fd;
- thedata.ioCompletion = 0;
- thedata.bufferLength = size;
- thedata.bufferPtr = writebuffer;
- thedata.more = 0;
- thedata.userData = 0;
- thedata.blockCreator = '????';
- thedata.blockType = '????';
- err = PPCWriteAsync(&thedata);
- err = waitforcompletion(&thedata.ioResult);
- return thedata.actualLength;
- }
-